<template>
  <div>
    <!-- 头部 -->
    <div class="header_box">
      <span>
        <img
          class="imgOne"
          src="~@/assets/duZhongTai/goHomeOne.png"
          alt=""
          srcset=""
        />
      </span>
      <span class="title">嘟中台</span>
      <span>
        <!-- <img class="imgTwo" src="~@/assets/duZhongTai/more.png" alt="" srcset="" /> -->
        <van-popover
          v-model="showPopover"
          trigger="click"
          @select="onSelect"
          placement="bottom-end"
        >
          <!--  :actions="actions" -->
          <template slot="reference">
            <!-- <van-button type="text" size="mini"> -->
            <img
              class="imgTwo"
              src="~@/assets/duZhongTai/more.png"
              alt=""
              srcset=""
            />
            <!-- </van-button> -->
          </template>
          <div
            v-for="(item, index) in actions"
            :key="index"
            class="popover_box"
          >
            <span :class="item.icon" @click="onSelect(item)">
              <span style="padding-left: 10px">{{ item.text }}</span>
            </span>
          </div>
        </van-popover>
      </span>
    </div>
    <!-- <van-icon
      class="iconfont icon-lajixiang"
      class-prefix="icon"
      name="icon-lajixiang"
    />
    <van-icon
      class="iconfont icon-dingzhuhuchu-weidingzhuzhuangtai"
      class-prefix="icon"
      name="icon-dingzhuhuchu-weidingzhuzhuangtai"
    /> -->

    <!-- 内容 -->
    <div class="content_box">
      <!-- 切换栏 -->
      <div class="tabs_box">
        <!-- <van-tabs type="card">
        <van-tab title="标签 1">内容 1</van-tab>
        <van-tab title="标签 2">内容 2</van-tab>
        <van-tab title="标签 3">内容 3</van-tab>
      </van-tabs> -->
        <van-tabs
          v-model="active"
          color="rgb(247,247,247)"
          background="rgb(247,247,247)"
          @click="choiceTabs(active)"
        >
          <van-tab title="标签" class="vant_tab_d">
            <div slot="title" class="badge_box">
              <span :class="active === 0 ? 'active' : ''">全部</span>
              <van-badge :content="200" max="89" class="van-badge_b">
                <div class="child" />
              </van-badge>
            </div>
            <div class="zhiixng_box">
              <div v-for="(item, index) of zhixingType" :key="index">
                <div>
                  <img :src="item.imgUrl" alt="" srcset="" />
                </div>
                <div>{{ item.name }}</div>
              </div>
            </div>
            <div>11111</div>
          </van-tab>
          <van-tab title="标签 2">
            <!-- <van-badge :content="200" max="99">
              <div class="child" />
            </van-badge> -->
            <div slot="title" class="badge_box">
              <span :class="active === 1 ? 'active' : ''">未读</span>
              <van-badge :content="200" max="89" class="van-badge_b">
                <div class="child" />
              </van-badge>
            </div>
            <div>
              <div class="zhiixng_box">
                <div v-for="(item, index) of zhixingType" :key="index">
                  <div>
                    <img :src="item.imgUrl" alt="" srcset="" />
                  </div>
                  <div>{{ item.name }}</div>
                </div>
              </div>
            </div>
            <div>222</div>
          </van-tab>
          <van-tab title="标签 3">
            <!-- <van-badge :content="200" max="99">
              <div class="child" />
            </van-badge> -->
            <div slot="title" class="badge_box">
              <span :class="active === 2 ? 'active' : ''">未处理</span>
              <van-badge :content="200" max="89" class="van-badge_b">
                <div class="child" />
              </van-badge>
            </div>
            <div>
              <div class="zhiixng_box">
                <div v-for="(item, index) of zhixingType" :key="index">
                  <div>
                    <img :src="item.imgUrl" alt="" srcset="" />
                  </div>
                  <div>{{ item.name }}</div>
                </div>
              </div>
            </div>
            <div>333</div>
          </van-tab>
          <van-tab title="标签 4">
            <!-- <van-badge :content="200" max="99">
              <div class="child" />
            </van-badge> -->
            <div slot="title" class="badge_box">
              <span :class="active === 3 ? 'active' : ''">已发出</span>
              <!-- <van-badge :content="200" max="89" class="van-badge_b">
                <div class="child" />
              </van-badge> -->
            </div>
            <div>
              <div class="zhiixng_box">
                <div v-for="(item, index) of zhixingType" :key="index">
                  <div>
                    <img :src="item.imgUrl" alt="" srcset="" />
                  </div>
                  <div>{{ item.name }}</div>
                </div>
              </div>
            </div>
            <div>444</div>
          </van-tab>
        </van-tabs>
        <van-tabs
          v-model="active"
          color="rgb(247,247,247)"
          background="rgb(247,247,247)"
          @click="choiceTabs(active)"
        >
          <van-tab
            title="标签"
            class="vant_tab_d"
            v-for="(item, index) in tabsList"
            :key="index"
          >
            <div slot="title" class="badge_box">
              <span :class="active === index ? 'active' : ''">{{
                item.name
              }}</span>
              <van-badge
                :content="item.contentNum"
                max="99"
                class="van-badge_b"
              >
                <div class="child" />
              </van-badge>
            </div>
            <div class="zhiixng_box">
              <div v-for="(item, index) of zhixingType" :key="index">
                <div>
                  <img :src="item.imgUrl" alt="" srcset="" />
                </div>
                <div>{{ item.name }}</div>
              </div>
            </div>
            <div>11111</div>
          </van-tab>
        </van-tabs>
      </div>
    </div>
    <div>
      我问问
      <van-tabs>
        <van-tab v-for="index in 8" :title="'标签 ' + index" :key="index">
          内容 {{ index }}
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script>
import Vue from "vue";

import { Popover } from "vant";
import { Icon } from "vant";
import { Tab, Tabs } from "vant";
import { Button } from "vant";
import { Badge } from "vant";

Vue.use(Badge);
Vue.use(Button);
Vue.use(Tab);
Vue.use(Tabs);

Vue.use(Icon);
Vue.use(Popover);
import { Toast } from "vant";
export default {
  data() {
    return {
      showPopover: false,
      active: 0,
      activeId: 0,
      // 通过 actions 属性来定义菜单选项
      actions: [
        { text: "回收站", icon: "iconfont icon-lajixiang" },
        { text: "搜索", icon: "iconfont icon-sousuo" },
        {
          text: "钉住",
          icon: "iconfont icon-dingzhuhuchu-weidingzhuzhuangtai",
        },
        { text: "批量管理", icon: "iconfont icon-piliangguanli" },
        { text: "home", icon: "iconfont icon-Homehomepagemenu" },
      ],
      tabsList: [
        {
          id: 1,
          name: "全部",
          value: "1",
          contentNum: "200",
        },
        {
          id: 2,
          name: "未读",
          value: "2",
          contentNum: "80",
        },
        {
          id: 3,
          name: "未处理",
          value: "3",
          contentNum: "18",
        },
        {
          id: 4,
          name: "已发出",
          value: "4",
          contentNum: "",
        },
      ],
      // 执行类数据
      zhixingType: [
        {
          id: 1,
          name: "执行类",
          imgUrl: require("../../../../assets/duZhongTai/zhixing.png"),
        },
        {
          id: 2,
          name: "预警类",
          imgUrl: require("../../../../assets/duZhongTai/yujing.png"),
        },
        {
          id: 3,
          name: "消息通知类",
          imgUrl: require("../../../../assets/duZhongTai/xiaoxi.png"),
        },
        // {
        //   id:4,
        //   name:"执行类",
        //   imgUrl:require("../../../../assets/duZhongTai/zhixing.png"),
        // },
      ],
    };
  },
  watch: {},
  activated() {},
  created() {},
  methods: {
    //点击右上角
    onSelect(action) {
      //   console.log("action=", action);
      console.log("action=", action.text);
      this.showPopover = false;
      //   Toast(action.text);
    },
    //点击tabs
    choiceTabs(active) {
      // console.log("123===", active);
      this.activeId = active;
      this.active = active;
      console.log("this.activeId==", this.activeId);
      console.log("this.active==", this.active);
    },
  },
  mounted() {},
};
</script>

<style scoped>
.header_box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 40px;
  line-height: 40px;
  /* border: 1px solid red; */
  padding: 0 10px;
}
.header_box .title {
  font-size: 20px;
}
.header_box .imgOne {
  /* width: 25px; */
  height: 25px;
}
.header_box .imgTwo {
  width: 40px;
  /* height: 25px; */
}
.popover_box {
  padding-left: 10px;
  line-height: 30px;
}
.content_box {
  background-color: rgb(247, 247, 247);
}
.zhiixng_box {
  display: flex;
  justify-content: space-around;
  align-items: center;
  text-align: center;
}
.zhiixng_box img {
  width: 4.375rem;
}
.tabs_box {
  background-color: #fff;
}
/* .vant_tab_d{
  position: relative;
} */
/* .van-tab{
   position: relative;
} */
.van-badge_b {
  position: absolute;
  top: -20%;
  right: -10%;
}
.badge_box {
  position: relative;
}
.active {
  color: rgb(73, 145, 242);
}
</style>
<style>
.van-popover {
  /* width: 110px;
  margin: 0px -17px !important; */
  width: 6.875rem;
  margin: 0px 0px !important;
}

/*  */
.van-tabs--line .van-tabs__wrap {
  width: 100%;
  border-radius: 50px;
  /* background-color: rgb(0,0,0); */
  /* border: 1px solid red; */
}
.van-tab__text--ellipsis {
  /* border: 1px solid #fff; */
  background: #fff;
  width: 75px;
  text-align: center;
  line-height: 30px;
  text-align: center;
  border-radius: 50px;
  overflow: inherit;

  /* position: relative; */
}
</style>